<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="utf-8">
	<title>首页--后台首页</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
	<blockquote class="layui-elem-quote layui-bg-green">
		<div id="nowTime"></div>
	</blockquote>

	<!--查看弹出层开始-->
	<div id="showNoticeDiv" style="display: none;padding: 10px">
		<h2 id="show_title" style="text-align: center"></h2>
		<div style="text-align: right">
			发布人：<span id="show_opername"></span>
			发布时间：<span id="show_createtime"></span>
		</div>
		<hr>
		<div id="show_content">

		</div>
	</div>
<!--	<div class="layui-row layui-col-space10">-->
<!--		<div class="layui-col-lg9 layui-col-md12">-->
<div style="width: 600px;border: none">
	<blockquote class="layui-elem-quote title">最新公告 <i class="layui-icon layui-red">&#xe756;</i></blockquote>
	<!--数据表格开始-->
	<div>
		<table class="layui-hide" id="noticeTable" lay-filter="noticeTable" lay-skin="nob"></table>
		<div id="noticeRowBar" style="display: none">
			<button type="button" lay-event="show"  class="layui-btn layui-btn-sm layui-btn-normal"><span class="layui-icon layui-icon-about"></span>查看</button>
		</div>
	</div>
	<!--数据表格结束-->
</div>

<!--		</div>-->
<!--	</div>-->

	<script type="text/javascript" src="/resources/layui/layui.js"></script>
	<script type="text/javascript">
		//获取系统时间
		var newDate = '';
		getLangDate();
		//值小于10时，在前面补0
		function dateFilter(date){
			if(date < 10){return "0"+date;}
			return date;
		}
		function getLangDate(){
			var currentUserName = '[[${session.user.name}]]'
			var dateObj = new Date(); //表示当前系统时间的Date对象
			var year = dateObj.getFullYear(); //当前系统时间的完整年份值
			var month = dateObj.getMonth()+1; //当前系统时间的月份值
			var date = dateObj.getDate(); //当前系统时间的月份中的日
			var day = dateObj.getDay(); //当前系统时间中的星期值
			var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
			var week = weeks[day]; //根据星期值，从数组中获取对应的星期字符串
			var hour = dateObj.getHours(); //当前系统时间的小时值
			var minute = dateObj.getMinutes(); //当前系统时间的分钟值
			var second = dateObj.getSeconds(); //当前系统时间的秒钟值
			var timeValue = "" +((hour >= 12) ? (hour >= 18) ? "晚上" : "下午" : "上午" ); //当前时间属于上午、晚上还是下午
			newDate = dateFilter(year)+"年"+dateFilter(month)+"月"+dateFilter(date)+"日 "+" "+dateFilter(hour)+":"+dateFilter(minute)+":"+dateFilter(second);
			document.getElementById("nowTime").innerHTML = "亲爱的【"+currentUserName+"】，"+timeValue+"好！ 欢迎使用仓库管理系统。当前时间为： "+newDate+"　"+week;
			setTimeout("getLangDate()",1000);
		}

		layui.use(['form','element','layer','jquery','table'],function(){
			// var form = layui.form,
			// 		layer = parent.layer === undefined ? layui.layer : top.layer,
			// 		element = layui.element;
			var form=layui.form;
			var layer=layui.layer;
			var element=layui.element;
			$ = layui.jquery;
			var table=layui.table;
			//上次登录时间【此处应该从接口获取，实际使用中请自行更换】
			$(".loginTime").html(newDate.split("日")[0]+"日</br>"+newDate.split("日")[1]);
			//icon动画
			$(".panel a").hover(function(){
				$(this).find(".layui-anim").addClass("layui-anim-scaleSpring");
			},function(){
				$(this).find(".layui-anim").removeClass("layui-anim-scaleSpring");
			})
			$(".panel a").click(function(){
				parent.addTab($(this));
			})

			//最新公告列表
			//表格数据渲染
			var tableIns=table.render({
				elem: '#noticeTable'
				,url:'/notice/loadAllNoticeToDeskManager'
				,toolbar: false //开启头部工具栏，并为其绑定左侧模板
				,title: '公告数据表'
				,height: 'full-200'
				,cols: [ [
					{field:'id', title:'ID',align: 'center',width:'80'}
					,{field:'title', title:'公告标题',align: 'center',width:'120'}
					,{field:'createtime', title:'发布时间',align: 'center',width:'180'}
					,{field:'opername', title:'发布人',align: 'center',width:'100'}
					,{fixed: 'right', title:'操作', toolbar: '#noticeRowBar',align: 'center',width:'80'}
				] ]
			});
			//行工具监听
			table.on("tool(noticeTable)", function(obj){
				var data=obj.data;
				switch(obj.event){
					case 'show':
						showNoticeLayer(data);
						break;
				}
			});
			//查看弹出层的设置
			function showNoticeLayer(data){
				mainIndex=layer.open({
					type: 1,
					title:'查看公告',
					content: $('#showNoticeDiv'),
					area:['500px','300px'],
					success: function () {
						$('#show_title').text(data.title);
						$('#show_opername').text(data.opername);
						$('#show_createtime').text(data.createtime);
						$('#show_content').text(data.content);
					}
				});
			}
		})
	</script>
</body>
</html>